<?php
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/activity.php');
require_once ('../lib/test.php');
require_once ('f:\wamp\www\simpletest\autorun.php');
require_once ('../lib/init.php');

class TestTemplate extends UnitTestCase {
    
    function setUp(){
        global $login_button;
        try{
        $me = getOneself();
        }catch(Exception $e){
            print($login_button);
            exit();
        }
    }
    
    //refer to http://www.simpletest.org/en/unit_test_documentation.html
    function testGetFriendCommentActivities(){ 

                     
        //sample data from var_export
        $data = array (
            'name' => 'friendCommentQuery',
            'fql_result_set' => 
            array (
              0 => 
              array (
                'fromid' => '612139051',
                'time' => '1286399988',
                'text' => 'No point in taking outta ur sleep time, only gonna be worse the next day. After major panic I finally got something half sorted today after 10 days of weeing in the wind. I hate android. Hope urs in going better.',
              ),
              1 => 
              array (
                'fromid' => '612139051',
                'time' => '1286472040',
                'text' => 'Preferably a direction which is well documented at all levels..stupid android!',
              ),
              2 => 
              array (
                'fromid' => '612139051',
                'time' => '1285873717',
                'text' => 'When ur doing a dissertation it\'s very understandable!',
              ),
              3 => 
              array (
                'fromid' => '612139051',
                'time' => '1285179920',
                'text' => 'Yaaaaay, oh the frustration of not having access. Have you got feedback from ur sup regarding ur initial report yet?',
              ),
              4 => 
              array (
                'fromid' => '612139051',
                'time' => '1285191347',
                'text' => 'Ah great, I\'m waiting on mine. I\'m battling thru the "Quiz" part of my app. No fun...',
              )
        ));
        
        $id = 612139051;
        $activities = array();
        $activities = getFriendCommentActivities($data, $activities);
        
        $this->assertTrue(is_array($activities));
        $this->assertTrue(count($activities) == 5);
        
        
        print_r($activities);
    }
    
    function testRealData(){
        $id = 612139051;
        $data = getActivities($id);
        $friendComment = getResultSet('friendCommentQuery', $data);
        $activities = array();
        $activities = getFriendCommentActivities($friendComment, $activities);
        
        $friendComment = $friendComment['fql_result_set'];
        $numberOfComment = count($friendComment);
        
        $this->assertTrue(is_array($activities));
        $this->assertEqual($numberOfComment, count($activities));
        print_r($activities);
    }
}
?>